<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义promise</title>
<!--    引入promise-->
    <script src="promise.js"></script>
</head>
<body>
  <script>
     const p = new Promise((resolve, reject) => {
        // resolve('ok');
        //  reject('Error');
        //  throw 'error';
         setTimeout(() => {
             resolve('ok');
         },1000)
     });
     p.then(value => {
       console.log(value);
     },reason => {
       console.log(reason);
     }); 
     p.then(value => {
       alert(value);
     },reason => {
       alert(reason);
     });
  </script>
</body>
</html>